require "codeclimate-test-reporter"
require 'minitest/autorun'
require 'simplecov'

SimpleCov.start
CodeClimate::TestReporter.start

require_relative '../lib/rstackoverflow'

class StackOverflowTest < Minitest::Test
  def test_search
    res = StackOverflow::Questions.search('hello world').first
    assert res
    assert res.id.is_a? Integer
    assert res.title
    assert res.abstract
    assert res.vote.is_a? Integer
    assert res.answer_count.is_a? Integer
  end

  def test_question
    res = StackOverflow::Questions.at(15182496)
    assert res
    assert res.id.is_a? Integer
    assert res.url
    assert res.title
    assert res.detail
    assert res.vote.is_a? Integer
    assert res.labels.is_a? Array
    assert res.comments
    assert res.answers.is_a? Array

    ans = res.answers.first
    assert ans
    assert ans.id.is_a? Integer
    assert ans.detail
    assert ans.accepted
    assert ans.vote.is_a? Integer
    assert ans.comments
  end
end
